package pa1.helloworld;


import java.rmi.Naming;
import java.rmi.registry.Registry;

import pa1.helloworld.Hello;

public class HelloClient extends Thread{
    @Override
	public void run()
    {
        String host = "localhost";
        String port = Integer.toString(Registry.REGISTRY_PORT);

        try {
        	String objects[] = Naming.list("rmi://" + host+ ":" + port + "/");
        	for(int i = 0; i < objects.length; i++){
        		System.out.println(objects[i]);
        	}
        	System.out.println("Looking up Hello at " + host + ":" + port);
            Hello obj = (Hello) Naming.lookup("//" + host + ":" + port + "/" + Hello.SERVICENAME);
        	
            System.out.println(obj.HelloRMI("User"));
            Info info = obj.HelloRMI2();
            for(int i = 0; i < 10; i++){
            	System.out.println(info.getLastCalled());
            	Thread.sleep(1000);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
